#include "VolumeMeta.h"

namespace OCPP
{namespace Volume{

    CVolumeMeta::CVolumeMeta()
        :mRoot(Json::Value(Json::objectValue))
    {

    }

    CVolumeMeta::~CVolumeMeta()
    {

    }

    String CVolumeMeta::toString()
    {
        Json::FastWriter writer;
        String jsonStr = writer.write(mRoot);
        return jsonStr;
    }

    void CVolumeMeta::setSize(float width, float height, float depth)
    {
        mRoot["size"]["width"] = width;
        mRoot["size"]["height"] = height;
        mRoot["size"]["depth"] = depth;
    }

    void CVolumeMeta::setPosition(float x, float y, float z)
    {
        mRoot["position"]["x"] =x;
        mRoot["position"]["y"] =y;
        mRoot["position"]["z"] =z;
    }

    void CVolumeMeta::setSourceFormat(int format, int type)
    {
        mRoot["source"]["pixelFormat"] = format;
        mRoot["source"]["pixelType"] = type;
    }

    void CVolumeMeta::setSource(int width, int height, int depth)
    {
        mRoot["source"]["width"] = width;
        mRoot["source"]["height"] = height;
        mRoot["source"]["depth"] = depth;
    }

    void CVolumeMeta::setExtent(CRectangle extent)
    {
        float west = extent.getMinimum().x;
        float south = extent.getMinimum().y;
        float east = extent.getMaximum().x;
        float north = extent.getMaximum().y;
        setExtent(west, south, east, north);
    }

    void CVolumeMeta::setExtent(float west,float south,float east,float north)
    {
        mRoot["rectangle"]["west"] = west;
        mRoot["rectangle"]["south"] = south;
        mRoot["rectangle"]["east"] = east;
        mRoot["rectangle"]["north"] = north;
    }
}}